package com.bw.comtroler;

import com.bw.bean.Sugar1;
import com.bw.bean.Sugar2;
import com.bw.service.SugarService;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class SugarController {
    @Autowired
    SugarService sugarService;

    @RequestMapping("/list1")
    public Map getList1(){
        List<Sugar1> list1 = sugarService.getList1();
        return SugarUtil.getMapData(list1);
    }

    @RequestMapping("/list2")
    public Map getList2(){
        List<Sugar1> list2 = sugarService.getList2();
        return SugarUtil.getBarData(list2);
    }

    @RequestMapping("/list3")
    public Map getList3(){
        List<Sugar1> list3 = sugarService.getList3();
        return SugarUtil.getPieData(list3);
    }

    @RequestMapping("/list4")
    public String getList4(){
        ArrayList<String> list = new ArrayList<>();
        List<Sugar1> list4 = sugarService.getList4();
        list.add("新用户");
        list.add("老用户");
        return SugarUtil.getTablePlayData(list,list4);
    }

    @RequestMapping("/list5")
    public Map getList5(){
        List<Sugar1> list5 = sugarService.getList5();
        return SugarUtil.getBarData(list5);
    }

    @RequestMapping("/list6")
    public Map getList6(){
        List<Sugar1> list6 = sugarService.getList6();
        return SugarUtil.getPieData(list6);
    }

    @RequestMapping("/list7")
    public Map getList7(){
        List<Sugar1> list7 = sugarService.getList7();
        return SugarUtil.getPieData(list7);
    }

    @RequestMapping("/list8")
    public String getList8(){
        ArrayList<String> list=new ArrayList<>();
        List<Sugar2> list8 = sugarService.getList8();
        list.add("品牌");
        list.add("性别");
        list.add("收益");
        return SugarUtil.getTablePlayData(list,list8);
    }

    @RequestMapping("/list9")
    public Map getList9(){
        HashMap<Object, Object> map = new HashMap<>();
        Double list9 = sugarService.getList9();
        map.put("status",0);
        map.put("data",list9);
        return map;
    }
    @RequestMapping("/list10")
    public String getList10(){
        ArrayList<String> list=new ArrayList<>();
        List<Sugar2> list10 = sugarService.getList10();
        list.add("类别");
        list.add("收益");
        return SugarUtil.getTablePlayData(list,list10);
    }

}
